import centerHeader from '../../components/center-header';
export default {
  components: {
    centerHeader
  },
  data() {
    return {
      checkedMsg: 0,
      dialogVisible: false,
      activitylist: [], //for循环list
      tNoticeContent: '', //dialog的对象渲染
      header: [{
        title: "通知公告",
        path: "/home/activity"
      }, ],
      currentPage: 1,
      count_num:20
    }
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.getNoticeList(val);
    },
    //时间戳转换
    timestampToTime(timestamp) {
      var that = this;
      var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var Y = date.getFullYear() + "-";
      var M =
        (date.getMonth() + 1 < 10 ?
          "0" + (date.getMonth() + 1) :
          date.getMonth() + 1) + "-";
      var D = date.getDate() + " ";
      var h = date.getHours() + ":";
      var m = date.getMinutes() + ":";
      var s = date.getSeconds();
      return Y + M + D
    },
    itemclick(id) {
      let that = this;
      that.getNoticeContent(id);
    },
    //获取公告详情
    getNoticeContent(id) {
      let that = this;
      that.axios.post('/cp/v1/Notice/getNoticeContent', {
        id: id
      }).then((res) => {
        if (res.data.code == 200) {
          that.tNoticeContent = res.data.data;
          that.dialogVisible = true;
        }
      })
    },
    getNoticeList(page) {
      this.axios.get('/cp/v1/Notice/getNoticeList', {
        params: {
          page: page
        }
      }).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          this.activitylist = res.data.data.notice_list;
          this.count_num=res.data.data.count_num;
        }
      })
    }
  },
  created() {
    let that = this;
    that.getNoticeList(1);
  }
}
